//-
//- Copyright (c) Microsoft. All rights reserved.
//- Licensed under the MIT license. See LICENSE file in the project root for full license information.
//-

extends ../layout

block js_doc_ready
  | if (initializeTeamFilter) { initializeTeamFilter() }

block content
  div.container
    if onboardingOrJoining
      if orgUser
        div.row
          div.col-md-8.col-lg-8.col-sm-8
            h1.huge Welcome!
            p.lead You're onboarded and ready to contribute & collaborate in the #{org.name} open source world.
            if org.inner.settings.trainingResources
              p Here are some useful links and resources to help get you up and running quickly.
              - var tr = org.inner.settings.trainingResources
              if tr.organization && tr.organization.length && tr.organization.length > 0
                ul.list-unstyled
                  each resource in tr.organization
                    li
                      p
                        a(href=resource.link, target='_new')
                          = resource.title + ' '
                          i.glyphicon.glyphicon-share-alt
                        if resource.text
                          br
                          small= resource.text
              if tr.corporate && tr.corporate.length && tr.corporate.length > 0
                ul.list-unstyled
                  each resource in tr.corporate
                    li
                      p
                        a(href=resource.link, target='_new')
                          = resource.title + ' '
                          i.glyphicon.glyphicon-share-alt
                        if resource.text
                          br
                          small= resource.text
              if tr.github && tr.github.length && tr.github.length > 0
                ul.list-unstyled
                  each resource in tr.github
                    li
                      p
                        a(href=resource.link, target='_new')
                          = resource.title + ' '
                          i.glyphicon.glyphicon-share-alt
                        if resource.text
                          br
                          small= resource.text

          div.col-md-4.col-lg-4.col-sm-4
            p
              img.img-thumbnail.img-responsive(src=orgUser.avatar(400), alt=(orgUser.name || orgUser.login))
            h3= orgUser.name
            h4= orgUser.login
            p(style='margin-top:18px')
              a.btn.btn-sm.btn-muted(href='https://github.com/' + org.name, target='_new') Open on GitHub
              if org && org.baseUrl
                p
                  a.btn.btn-sm.btn-muted(href=org.baseUrl) #{org.name} Portal

    if isSudoer || userIsMaintainer
      h1
        | Teams&nbsp;
        if isSudoer
          small including sudoer options
    else
      div.row
        div.col-md-8.col-lg-8.col-sm-8
          h1 Join a team
          p All GitHub users have read permissions on all public repos. You can use the standard fork and pull-request GitHub workflow and contribute to any repo you can read. That's what open source is all about!

          p Joining a team gets you <a href="https://help.github.com/articles/repository-permission-levels-for-an-organization/" target="_new">more access to more repos</a>. For example, join a team to:

          ul
            li See private repos&mdash;they can only be seen by members of a team granted access.
            li Merge PRs, manage issues&mdash;needed to change content, accept pull requests, &hellip;.
            li Administer&mdash;needed to manage a repo's settings, and protected branches.
          p To get these additional permissions, you need to join a team that has the permission you want.

        div.col-md-4.col-lg-4.col-sm-4
          if org && org.name
            h3 Need help finding a team?

            p Sometimes it's easiest to start with a repo you want to work on and find its associated teams.
            p
              a.btn.btn.btn-default(href='/' + org.name + '/repos') Explore repos. Find teams to join


    if highlightedTeams && highlightedTeams.length
      h3 Recommended Team#{highlightedTeams.length > 1 ? 's' : ''}
      each ht in highlightedTeams
        if ht && ht.name
          h4= ht.name
        p= ht.description
        p
          if ht._hack_isMember === true
            if isSudoer || (userTeamsMaintainedById && userTeamsMaintainedById[ht.id])
              a.btn.btn-sm.btn-primary(href='/' + ht.org.name + '/teams/' + ht.slug) Manage this team
            else
              a.btn.btn-sm.btn-muted(href='/' + ht.org.name + '/teams/' + ht.slug + '/join') Already a member
          else
            a.btn.btn-default.btn-sm(href='/' + ht.org.name + '/teams/' + ht.slug + '/join') Request to join

    if availableTeams && availableTeams.length && availableTeams.length > 0
      if org
        h3.capitalize #{org.name} teams
      else
        h3 All teams across organizations

      table.table#teams-table
        thead
          tr
            th.thirtypercent Team
            if !org
              th.fifteenpercent Organization
            th Description
            if isSudoer
              th.thirtypercent Actions
            else
              th Actions
        tbody
          each availableTeam in availableTeams
            if availableTeam.hidden
              //- Some teams are hidden from view when they are not designed for general use, such as continuous integration servers
            else
              tr
                td
                  p
                    = availableTeam.name
                    if availableTeam.name != availableTeam.slug
                      br
                      small= availableTeam.slug
                    != '<!-- ' + availableTeam.slug + ':' + availableTeam.id + ' -->'
                if !org
                  td
                    if availableTeam.org
                      small= availableTeam.org.name
                td
                  p= availableTeam.description
                td
                  p
                    if availableTeam._hack_isMember === true
                      if userTeamsMaintainedById && userTeamsMaintainedById[availableTeam.id]
                        a.btn.btn-sm.btn-primary(href='/' + availableTeam.org.name + '/teams/' + availableTeam.slug) Manage this team
                      else
                        a.btn.btn-sm.btn-muted(href='/' + availableTeam.org.name + '/teams/' + availableTeam.slug + (isSudoer ? '' : '/join')) Already a member
                    else
                      if isSudoer
                        a.btn.btn-muted.btn-sm(href='/' + availableTeam.org.name + '/teams/' + availableTeam.slug) Manage as sudoer
                        | &nbsp;
                      a.btn.btn-default.btn-sm(href='/' + availableTeam.org.name + '/teams/' + availableTeam.slug + '/join') Request to join

    else
      p No additional teams are available at this time.
